package com.tsky.yyj.manager.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.tsky.casing.orm.impl.EntityManagerImpl;
import com.tsky.yyj.entity.Consumer;
import com.tsky.yyj.manager.ConsumerManager;

@Repository("consumerManager")
public class ConsumerManagerImpl  extends EntityManagerImpl implements ConsumerManager  {


	public Object queryByCode(String code) {
		
		Criteria ctr = this.getSession().createCriteria(Consumer.class);
		ctr.add(Restrictions.eq("code", code));
		

		List<?> resultList = ctr.list();

		return resultList.isEmpty() ? null : resultList.get(0);
		
	}
	
	public Object userLogin(String code, String password) {
		
		Criteria ctr = this.getSession().createCriteria(Consumer.class);
		ctr.add(Restrictions.eq("code", code));
		ctr.add(Restrictions.eq("password", password));

		List<?> resultList = ctr.list();

		return resultList.isEmpty() ? null : resultList.get(0);
	}

}
